var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var ResKeeper = require("AA_ResKeeper");
var Excel = require("AA_Excel");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_GongGaoView = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.content = null;
    t.back = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onEnable = function () {};
  _creator.prototype.initUi = function (e) {
    this.back = e;
    var t = this.getNewGongGao()[0].content;
    var o = this.content.children;
    var n = Math.max(t.length, o.length);
    for (var i = 0; i < n; i++) {
      var a = o[i];
      var r = t[i];
      if (r) {
        if (!a) {
          a = cc.instantiate(o[0]);
          this.content.addChild(a);
        }
        a.getComponent(cc.Label).string = r;
      } else {
        a && (a.active = false);
      }
    }
  };
  _creator.prototype.getNewGongGao = function () {
    var e = this;
    var t = Excel.Excel.shuiguogonggao_all;
    var o = t.size;
    var n = [];
    for (var i = 0; i < o; i++) {
      var a = t.get(i + 1);
      this.getServerTime(a.time);
      new Date().getTime();
      1 == a.isshow && n.push(a);
    }
    n.sort(function (t, o) {
      if (e.getServerTime(t.time) > e.getServerTime(o.time)) {
        return -1;
      } else {
        return 1;
      }
    });
    return n;
  };
  _creator.prototype.getServerTime = function (e) {
    return new Date(e).getTime();
  };
  _creator.prototype.onClose = function () {
    this.dingyueGong();
    this.node.active = false;
    this.back && this.back();
  };
  _creator.prototype.dingyueGong = function () {
    if (window.tt || window.wx) {
      var e = null;
      try {
        e = YPSDK.Common.curChannelData.appId;
      } catch (e) {}
      if (!e) {
        return false;
      }
      var t = undefined;
      console.log(e);
      switch (e) {
        case "tt09297f94961f881b02":
          t = ["MSG1846453137157385400476860254502"];
          break;
        case "tt667d10c0f94297cd02":
        case "tt61e41759feda70e102":
        case "ttc50db3b05a31141c02":
        case "wx6baaaa27ab5186ff":
        case "wx62fa4e9975f65d7c":
          break;
        case "wxc1140fe25421fe29":
          t = ["vkfuhf-ds7r7mJ6v991ibuONP439Ca88L6f4VmEITc0"];
      }
      console.log(t);
      if (!t) {
        return false;
      }
      if (window.tt) {
        window.tt.requestSubscribeMessage && window.tt.requestSubscribeMessage({
          tmplIds: t,
          complete: function () {}
        });
      } else {
        window.wx && window.wx.requestSubscribeMessage && window.wx.requestSubscribeMessage({
          tmplIds: t,
          success: function () {}
        });
      }
    }
  };
  _creator.prototype.onDisable = function () {};
  __decorate([_property(cc.Node)], _creator.prototype, "content", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_GongGaoView;